package day2;

import org.junit.Test;

import java.util.Arrays;
import java.util.Scanner;

public class ArrayInputSumAvg {
    @Test
    public void tes1t03(){
        Scanner sc=new Scanner(System.in);
        int [] arr=new int[3];
        int count =0;
        while(true){
            int num=sc.nextInt();
            if(num<=0){
                break;
            }
            if(count>=arr.length){
                int[] temp=new int[arr.length*2];
                System.arraycopy(arr,0,temp,0,arr.length);
                arr=temp;
            }
            arr[count]=num;
            count++;
        }
        System.out.println("有效数据个数:"+count);
        int[] result =new int[count];
        System.arraycopy(arr,0,result,0,count);
        System.out.println(Arrays.toString(result));
    }
}
